package com.yjy.mybase.fragment;

import android.os.Bundle;


import androidx.annotation.Nullable;

import com.yjy.mybase.mvp.BaseContract;
import com.yjy.mybase.mvp.MVPBasePresenter;

/**
 * Created by admin on 2016/11/1.
 */
public abstract class MVPBaseFragment<P extends MVPBasePresenter> extends BaseFragment implements BaseContract.View {
    protected P mPresenter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        mPresenter = createPresenter();
        if (mPresenter != null) {
            mPresenter.attach(this);
        }
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onDestroy() {
        if (mPresenter != null) {
            mPresenter.detach();
        }
        super.onDestroy();
    }


    protected abstract P createPresenter();
}
